package com.navinfo.opentsp.platform.computing.dto;


import com.navinfo.opentsp.platform.computing.util.EntityConvert;
import com.navinfo.opentsp.platform.location.protocol.common.LCPredictiveMaintenance;

public class MaintenanceEventE0Dto {

  private int	temperature1;	//货箱温度1
  private int	temperature2;	//货箱温度2
  private int	temperature3;	//货箱温度3
  private int	temperature4;	//货箱温度4
  private int	humidity1	;  //货箱湿度1
  private int	humidity2	;  //货箱湿度2
  private int	humidity3	;  //货箱湿度3
  private int	humidity4	;  //货箱湿度4
  private int	doorStatusLeft	;  //货箱左侧车门状态-车门开启报警
  private int	doorStatusRight	;  //货箱右侧车门状态-车门开启报警
  private int	doorStatusBack	;  //货箱后门车门状态-车门开启报警



    public int getTemperature1() {
        return temperature1;
    }

    public void setTemperature1(int temperature1) {
        this.temperature1 = temperature1;
    }

    public int getTemperature2() {
        return temperature2;
    }

    public void setTemperature2(int temperature2) {
        this.temperature2 = temperature2;
    }

    public int getTemperature3() {
        return temperature3;
    }

    public void setTemperature3(int temperature3) {
        this.temperature3 = temperature3;
    }

    public int getTemperature4() {
        return temperature4;
    }

    public void setTemperature4(int temperature4) {
        this.temperature4 = temperature4;
    }

    public int getHumidity1() {
        return humidity1;
    }

    public void setHumidity1(int humidity1) {
        this.humidity1 = humidity1;
    }

    public int getHumidity2() {
        return humidity2;
    }

    public void setHumidity2(int humidity2) {
        this.humidity2 = humidity2;
    }

    public int getHumidity3() {
        return humidity3;
    }

    public void setHumidity3(int humidity3) {
        this.humidity3 = humidity3;
    }

    public int getHumidity4() {
        return humidity4;
    }

    public void setHumidity4(int humidity4) {
        this.humidity4 = humidity4;
    }

    public int getDoorStatusLeft() {
        return doorStatusLeft;
    }

    public void setDoorStatusLeft(int doorStatusLeft) {
        this.doorStatusLeft = doorStatusLeft;
    }

    public int getDoorStatusRight() {
        return doorStatusRight;
    }

    public void setDoorStatusRight(int doorStatusRight) {
        this.doorStatusRight = doorStatusRight;
    }

    public int getDoorStatusBack() {
        return doorStatusBack;
    }

    public void setDoorStatusBack(int doorStatusBack) {
        this.doorStatusBack = doorStatusBack;
    }

    public static MaintenanceEventE0Dto parseProto(LCPredictiveMaintenance.MaintenanceEventE0 maintenanceEventE0){
        MaintenanceEventE0Dto maintenanceEventE0Dto = new MaintenanceEventE0Dto();
        maintenanceEventE0Dto.setTemperature1(maintenanceEventE0.getTemperature1());
        maintenanceEventE0Dto.setTemperature2(maintenanceEventE0.getTemperature2());
        maintenanceEventE0Dto.setTemperature3(maintenanceEventE0.getTemperature3());
        maintenanceEventE0Dto.setTemperature4(maintenanceEventE0.getTemperature4());
        maintenanceEventE0Dto.setHumidity1(maintenanceEventE0.getHumidity1());
        maintenanceEventE0Dto.setHumidity2(maintenanceEventE0.getHumidity2());
        maintenanceEventE0Dto.setHumidity3(maintenanceEventE0.getHumidity3());
        maintenanceEventE0Dto.setHumidity4(maintenanceEventE0.getHumidity4());
        maintenanceEventE0Dto.setDoorStatusLeft(maintenanceEventE0.getDoorStatusLeft());
        maintenanceEventE0Dto.setDoorStatusRight(maintenanceEventE0.getDoorStatusRight());
        maintenanceEventE0Dto.setDoorStatusBack(maintenanceEventE0.getDoorStatusBack());
        return maintenanceEventE0Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEventE0
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEventE0 maintenanceEventE0){
        return EntityConvert.convert(
                maintenanceEventE0.getTemperature1(),
        maintenanceEventE0.getTemperature2(),
        maintenanceEventE0.getTemperature3(),
        maintenanceEventE0.getTemperature4(),
        maintenanceEventE0.getHumidity1(),
        maintenanceEventE0.getHumidity2(),
        maintenanceEventE0.getHumidity3(),
        maintenanceEventE0.getHumidity4(),
        maintenanceEventE0.getDoorStatusLeft(),
        maintenanceEventE0.getDoorStatusRight(),
        maintenanceEventE0.getDoorStatusBack()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEventE0 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEventE0.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=11){
                builder = LCPredictiveMaintenance.MaintenanceEventE0.newBuilder();
                builder.setTemperature1(Integer.valueOf(revert[0]));
                builder.setTemperature2(Integer.valueOf(revert[1]));
                builder.setTemperature3(Integer.valueOf(revert[2]));
                builder.setTemperature4(Integer.valueOf(revert[3]));
                builder.setHumidity1(Integer.valueOf(revert[4]));
                builder.setHumidity2(Integer.valueOf(revert[5]));
                builder.setHumidity3(Integer.valueOf(revert[6]));
                builder.setHumidity4(Integer.valueOf(revert[7]));
                builder.setDoorStatusLeft(Integer.valueOf(revert[8]));
                builder.setDoorStatusRight(Integer.valueOf(revert[9]));
                builder.setDoorStatusBack(Integer.valueOf(revert[10]));
//                builder.setDoorStatus(Integer.valueOf(revert[8]));


            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }

}
